export default {
  setItem(key, value) {
    localStorage.setItem(key, JSON.stringify(value))
  },

  getItem(key) {
    try {
      const value = localStorage.getItem(key)
      if (value === null || value === undefined || value === '') {
        return null
      }
      return JSON.parse(localStorage.getItem(key))
    } catch (err) {
      return null
    }
  },

  removeItem(key) {
    localStorage.removeItem(key)
  },

  clear() {
    localStorage.clear()
  }
}
